Skip to content

Conversation

D00E
Copy link

@D00E D00E commented Oct 3, 2025

Pull Request Readiness Checklist

See details at https://github.com/opencv/opencv/wiki/How_to_contribute#making-a-good-pull-request

I agree to contribute to the project under Apache 2 License.
x To the best of my knowledge, the proposed patch is not based on a code under GPL or another license that is incompatible with OpenCV
x The PR is proposed to the proper branch
x There is a reference to the original bug report and related work
There is accuracy test, performance test and test data in opencv_extra repository, if applicable
x Patch to opencv_extra has the same branch name.

The feature is well documented and sample code can be built with the project CMake

Description

Is in support to a pull request regarding, issue opencv/opencv#26476.
Core paired pull request: opencv/opencv#27810
This adds function templates inline with the pure virtual overloaded apply function present for background subtraction. Supporting the build of the pull request:

@D00E D00E force-pushed the known-foreground-mask branch from 28b9ac4 to 9b0a011 Compare October 3, 2025 19:59
@D00E D00E changed the title Resubmission Paired PR Rename, Compatibility with core repos, pure virtual overload foreground masking Optional Known Foreground Mask for Background Subtractors Oct 3, 2025
@D00E D00E changed the title Optional Known Foreground Mask for Background Subtractors In support of Optional Known Foreground Mask for Background Subtractors Oct 3, 2025
@D00E D00E force-pushed the known-foreground-mask branch from 9b0a011 to 0813a2f Compare October 3, 2025 22:00
@asmorkalov asmorkalov self-requested a review October 4, 2025 10:25
@asmorkalov asmorkalov self-assigned this Oct 4, 2025
@D00E D00E force-pushed the known-foreground-mask branch from 0813a2f to 7deee2b Compare October 4, 2025 20:53
@asmorkalov
Copy link
Contributor

@D00E Thanks a lot for the refresh. Looks like similar patch should be applied to cudabgsegm and cudalegacy modules too. See CI failures.

@asmorkalov asmorkalov self-requested a review October 6, 2025 08:24
@D00E
Copy link
Author

D00E commented Oct 6, 2025

Thanks for the heads up, @asmorkalov , this has now been sorted :) should be ready to go

@asmorkalov
Copy link
Contributor

There are CUDA build errors still:

opencv_contrib/modules/cudabgsegm/src/mog.cpp
/home/ci/opencv_contrib/modules/cudabgsegm/src/mog.cpp:83:122: error: default argument missing for parameter 5 of 'virtual void {anonymous}::MOGImpl::apply(cv::InputArray, cv::InputArray, cv::OutputArray, double, cv::cuda::Stream&)'
   83 |         void apply(InputArray image, InputArray knownForegroundMask, OutputArray fgmask, double learningRate=-1, Stream& stream) CV_OVERRIDE;
      |                                                                                                                  ~~~~~~~~^~~~~~
/home/ci/opencv_contrib/modules/cudabgsegm/src/mog.cpp:83:97: note: ...following parameter 4 which has a default argument
   83 |         void apply(InputArray image, InputArray knownForegroundMask, OutputArray fgmask, double learningRate=-1, Stream& stream) CV_OVERRIDE;
      |                                                                                          ~~~~~~~^~~~~~~~~~~~~~~
/home/ci/opencv_contrib/modules/cudabgsegm/src/mog.cpp:137:10: error: 'BackgroundSubtractorMOGImpl' has not been declared
  137 |     void BackgroundSubtractorMOGImpl::apply(InputArray _image, InputArray _knownForegroundMask, OutputArray _fgmask, double learningRate){
      |          ^~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/ci/opencv_contrib/modules/cudabgsegm/src/mog.cpp: In function 'void {anonymous}::apply(cv::InputArray, cv::InputArray, cv::OutputArray, double)':
/home/ci/opencv_contrib/modules/cudabgsegm/src/mog.cpp:143:32: error: invalid initialization of reference of type 'cv::OutputArray' {aka 'const cv::_OutputArray&'} from expression of type 'double'
  143 |         apply(_image, _fgmask, learningRate, Stream::Null());
      |                                ^~~~~~~~~~~~
/home/ci/opencv_contrib/modules/cudabgsegm/src/mog.cpp:137:109: note: in passing argument 3 of 'void {anonymous}::apply(cv::InputArray, cv::InputArray, cv::OutputArray, double)'
  137 |     void BackgroundSubtractorMOGImpl::apply(InputArray _image, InputArray _knownForegroundMask, OutputArray _fgmask, double learningRate){
      |                                                                                                 ~~~~~~~~~~~~^~~~~~~
/home/ci/opencv_contrib/modules/cudabgsegm/src/mog.cpp: At global scope:
/home/ci/opencv_contrib/modules/cudabgsegm/src/mog.cpp:146:10: error: 'BackgroundSubtractorMOGImpl' has not been declared
  146 |     void BackgroundSubtractorMOGImpl::apply(InputArray _image, InputArray _knownForegroundMask, OutputArray _fgmask, double learningRate, Stream &stream){
      |          ^~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/ci/opencv_contrib/modules/cudabgsegm/src/mog.cpp: In function 'void {anonymous}::apply(cv::InputArray, cv::InputArray, cv::OutputArray, double, cv::cuda::Stream&)':
/home/ci/opencv_contrib/modules/cudabgsegm/src/mog.cpp:152:52: error: no matching function for call to 'apply(const cv::_InputArray&, const cv::_OutputArray&, double&, cv::cuda::Stream&)'
  152 |         apply(_image, _fgmask, learningRate, stream);
      |                                                    ^
/home/ci/opencv_contrib/modules/cudabgsegm/src/mog.cpp:137:10: note: candidate: 'void {anonymous}::apply(cv::InputArray, cv::InputArray, cv::OutputArray, double)'
  137 |     void BackgroundSubtractorMOGImpl::apply(InputArray _image, InputArray _knownForegroundMask, OutputArray _fgmask, double learningRate){
      |          ^~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/ci/opencv_contrib/modules/cudabgsegm/src/mog.cpp:137:109: note:   no known conversion for argument 3 from 'double' to 'cv::OutputArray' {aka 'const cv::_OutputArray&'}
  137 |     void BackgroundSubtractorMOGImpl::apply(InputArray _image, InputArray _knownForegroundMask, OutputArray _fgmask, double learningRate){
      |                                                                                                 ~~~~~~~~~~~~^~~~~~~
/home/ci/opencv_contrib/modules/cudabgsegm/src/mog.cpp:146:10: note: candidate: 'void {anonymous}::apply(cv::InputArray, cv::InputArray, cv::OutputArray, double, cv::cuda::Stream&)'
  146 |     void BackgroundSubtractorMOGImpl::apply(InputArray _image, InputArray _knownForegroundMask, OutputArray _fgmask, double learningRate, Stream &stream){
      |          ^~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/ci/opencv_contrib/modules/cudabgsegm/src/mog.cpp:146:10: note:   candidate expects 5 arguments, 4 provided
/home/ci/opencv_contrib/modules/cudabgsegm/src/mog.cpp: At global scope:
/home/ci/opencv_contrib/modules/cudabgsegm/src/mog.cpp:83:14: warning: 'virtual void {anonymous}::MOGImpl::apply(cv::InputArray, cv::InputArray, cv::OutputArray, double, cv::cuda::Stream&)' used but never defined
   83 |         void apply(InputArray image, InputArray knownForegroundMask, OutputArray fgmask, double learningRate=-1, Stream& stream) CV_OVERRIDE;
      |              ^~~~~
/home/ci/opencv_contrib/modules/cudabgsegm/src/mog.cpp:82:14: warning: 'virtual void {anonymous}::MOGImpl::apply(cv::InputArray, cv::InputArray, cv::OutputArray, double)' used but never defined
   82 |         void apply(InputArray image, InputArray knownForegroundMask, OutputArray fgmask, double learningRate=-1) CV_OVERRIDE;
      |              ^~~~~
/home/ci/opencv_contrib/modules/cudabgsegm/src/mog.cpp:146:10: warning: 'void {anonymous}::apply(cv::InputArray, cv::InputArray, cv::OutputArray, double, cv::cuda::Stream&)' defined but not used [-Wunused-function]
  146 |     void BackgroundSubtractorMOGImpl::apply(InputArray _image, InputArray _knownForegroundMask, OutputArray _fgmask, double learningRate, Stream &stream){
      |          ^~~~~~~~~~~~~~~~~~~~~~~~~~~

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants